<?php

namespace App\Http\Validations\Admin;

use Illuminate\Contracts\Validation\Validator;
use Illuminate\Validation\Rule;

class MemberValidation {
    public function create() {
        $rules = [
            'medium_avatar'=>['required'],
            'username'=>['required','unique:user'],
            'truename'=>['required'],
            'nickname'=>['required'],
            'email'=>['required','email','unique:user'],
            'mobile'=>['required','regex:/^((13[0-9])|(14[5,7])|(15[0-3,5-9])|(17[0,3,5-8])|(18[0-9])|166|198|199|(147))\d{8}$/','unique:user'],
            'org_id'=>['required'],
            'post_id'=>['required']
        ];
        $attributes = [
            'medium_avatar'=>'头像',
            'username'=>'用户名',
            'truename'=>'真实姓名',
            'nickname'=>'昵称',
            'email'=>'邮箱',
            'mobile'=>'手机',
            'org_id'=>'组织机构',
            'post_id'=>'岗位',
        ];
        return ['rules' =>$rules,
            'attributes' => $attributes,
            'messages' => [
                'email.email'=>"邮箱格式不正确"
            ]
        ];
    }
    public function update() {
        $rules = [
            'medium_avatar'=>['required'],
            'email'=>['required','email',Rule::unique('user')->ignore(request('id'))],
            'mobile'=>['required','regex:/^((13[0-9])|(14[5,7])|(15[0-3,5-9])|(17[0,3,5-8])|(18[0-9])|166|198|199|(147))\d{8}$/',Rule::unique('user')->ignore(request('id'))],
            'org_id'=>['required'],
            'post_id'=>['required']
        ];
        $attributes = [
            'medium_avatar'=>'头像',
            'email'=>'邮箱',
            'mobile'=>'手机',
            'org_id'=>'组织机构',
            'post_id'=>'岗位',
        ];
        return ['rules' =>$rules,
            'attributes' => $attributes,
            'messages' => [
                'email.email'=>"邮箱格式不正确"
            ]
        ];
    }
    public function profile() {
        $rules = [
            'truename'=>['required'],
            'idcard'=>['required'],
            'city'=>['required'],
            'education'=>['required'],
            'job'=>['required']
        ];
        $attributes = [
            'truename'=>'真实姓名',
            'idcard'=>'身份证号',
            'city'=>'城市',
            'education'=>'学历',
            'job'=>'职位',

        ];
        return ['rules' =>$rules,
            'attributes' => $attributes,
            'messages' => [
            ]
        ];
    }
    //验证后添加的钩子函数
    public function customValidate(Validator $validator) {
        //
    }
}
